Optimal. Leaf size=65 \[ -\sqrt {a-b} \text {ArcTan}\left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \tanh ^{-1}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.03, antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3742, 399, 223,
212, 385, 209} \begin {gather*} -\sqrt {a-b} \text {ArcTan}\left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \tanh ^{-1}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 209
Rule 212
Rule 223
Rule 385
Rule 399
Rule 3742
Rubi steps
\begin {align*} \int \sqrt {a+b \cot ^2(x)} \, dx &=-\text {Subst}\left (\int \frac {\sqrt {a+b x^2}}{1+x^2} \, dx,x,\cot (x)\right )\\ &=-\left (b \text {Subst}\left (\int \frac {1}{\sqrt {a+b x^2}} \, dx,x,\cot (x)\right )\right )+(-a+b) \text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right )\\ &=-\left (b \text {Subst}\left (\int \frac {1}{1-b x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )\right )+(-a+b) \text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )\\ &=-\sqrt {a-b} \tan ^{-1}\left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \tanh ^{-1}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.17, size = 78, normalized size = 1.20 \begin {gather*} \sqrt {a-b} \text {ArcTan}\left (\frac {-\cot (x) \sqrt {a+b \cot ^2(x)}+\sqrt {b} \csc ^2(x)}{\sqrt {a-b}}\right )+\sqrt {b} \log \left (-\sqrt {b} \cot (x)+\sqrt {a+b \cot ^2(x)}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [B] Leaf count of result is larger than twice the leaf count of optimal. \(140\) vs.
\(2(53)=106\).
time = 0.18, size = 141, normalized size = 2.17
method | result | size |
derivativedivides | \(-b \left (\frac {\ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}\right )}{\sqrt {b}}-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}}\right )}{b^{2} \left (a -b \right )}\right )-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}}\right )}{b^{2} \left (a -b \right )}\) | \(141\) |
default | \(-b \left (\frac {\ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}\right )}{\sqrt {b}}-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}}\right )}{b^{2} \left (a -b \right )}\right )-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \left (\cot ^{2}\left (x \right )\right )}}\right )}{b^{2} \left (a -b \right )}\) | \(141\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 124 vs.
\(2 (53) = 106\).
time = 2.59, size = 515, normalized size = 7.92 \begin {gather*} \left [\frac {1}{2} \, \sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ) + \frac {1}{2} \, \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ), -\sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) + \frac {1}{2} \, \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ), \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right ) + \frac {1}{2} \, \sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ), -\sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) + \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right )\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \sqrt {a + b \cot ^{2}{\left (x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 210 vs.
\(2 (53) = 106\).
time = 1.72, size = 210, normalized size = 3.23 \begin {gather*} -\frac {1}{2} \, {\left (\frac {2 \, \sqrt {-a + b} b \arctan \left (\frac {{\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} + a - 2 \, b}{2 \, \sqrt {a b - b^{2}}}\right )}{\sqrt {a b - b^{2}}} + \sqrt {-a + b} \log \left ({\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2}\right )\right )} \mathrm {sgn}\left (\sin \left (x\right )\right ) - \frac {{\left (2 \, \sqrt {-a + b} b \arctan \left (\frac {\sqrt {-a + b} \sqrt {b}}{\sqrt {a b - b^{2}}}\right ) - \sqrt {a b - b^{2}} \sqrt {-a + b} \log \left (-a - 2 \, \sqrt {-a + b} \sqrt {b} + 2 \, b\right )\right )} \mathrm {sgn}\left (\sin \left (x\right )\right )}{2 \, \sqrt {a b - b^{2}}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.02 \begin {gather*} \int \sqrt {b\,{\mathrm {cot}\left (x\right )}^2+a} \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________